<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=640px,user-scalable=no,target-densitydpi=device-dpi" />
		<link rel="stylesheet" href="../css/css.css" type="text/css" />
		<script type="text/javascript" src='../js/jquery.min.js'></script>
		<script type="text/javascript" src='../js/main_in.js'></script>
		<script type="text/javascript" src='../js/common.js'></script>
		<title>密码修改</title>
		<script type="text/javascript">
			var uid = window.localStorage["uid"];
			getuser();    //获取当前账号信息
			
function doadd(){
	var LoginName = $("#acc_LoginName").val();
                    var Password = $("#acc_Password").val();
                    var Passworddd = $("#acc_Passworddd").val();
                    var Passwordcc = $("#acc_Passwordcc").val();
                    var hide_pass = $("#hide_pass").html();
                    
                    if(Password == '' ){
                        alert("密码不能为空");
                        return false;
                    }
                    
                    if(Password != hide_pass  ){
                        alert("原密码不正确");
                        return false;
                    }
                    
                    if(Passwordcc != Passworddd ){
                        alert("新密码不一致");
                        return false;
                    }   
                    
                    var passlength =  Passworddd.length;
                    if(passlength < 6 || passlength > 16){
                        alert("密码必须大于6位小于16位");
                        return false;
                    }
                    
                    var where = "?id=" + uid;
                    var body = {
                        "Token":"22e8f734-dae9-494e-a743-4c4a64af4ce2",
                        "Password":Passworddd,
                    }
                    
                    if(confirm("确认提交？")){
                    	var wt=plus.nativeUI.showWaiting();
                        $.ajax({
                            url: "http://api.unair.cn/api/userbl" + where,
                            type: "PUT",
                            data: body,
                            success: function (data) {
                            	var w=plus.nativeUI.showWaiting("修改成功");
								w.onclose=function(){
									clearInterval(t);
								}
                                var t=setInterval(function(){
									w.setTitle("修改成功");
									w.close();
									exit();
									clearInterval(t);
									wt.close();
								},1000);
                            },
                            error: function (data) {
                            	var w=plus.nativeUI.showWaiting("修改失败");
								w.onclose=function(){
									clearInterval(t);
								}
                                var t=setInterval(function(){
									w.setTitle("修改失败");
									w.close();
									clearInterval(t);
									wt.close();
								},1000);
                            }

                        });
                    };
}

			function exit(){
				localStorage.setItem("loginname",'');
                localStorage.setItem("password",'');
                localStorage.setItem("lgname", '');
                localStorage.setItem("uid", '');
                localStorage.setItem("name", '');
                localStorage.setItem("RecommendBy", '');
                jump_login();
			}
			
			function jump_login(){
				clicked("../user/login.html");
			}
			
function getuser(){
    var where =  "id = " + uid;
                var body = {"TableName": "Users", "PKName": "ID", "where": where };

                $.ajax({
                    url: "http://api.unair.cn/api/PagingQuery",
                    type: "POST",
                    data: body,
                    success: function(data) {
                        data = eval("(" + data.ResTable + ")");
                        $.each(data, function(k, v) {
                            $("#acc_LoginName").val(v.LoginName);
                            $("#hide_pass").html(v.Password);
                        })
                    },
                    error: function(data) {
//                        alert(data)
                    }
                });
}  
		</script>
	</head>
	<body>
		<div style="display: none;" id="hide_pass"></div>
        <div class="app_head">
            <div class="app_prev" onclick="clicked('../myinfo/myinfo.html')"><img src="../img/arrow.png" /></div>
            <div class="app_head_text">密码修改</div>
            <div class="app_prev"></div>
        </div>
        <div class="app_body">
            <div class="main_in_input">
                <div class="main_in_input_img"><img src="../img/icon.png" /></div>
                <div class="main_in_input_text"><input type="text" id="acc_LoginName" placeholder="请输入手机号" readonly /></div>
                <input type="hidden" id="number" />
            </div>
            <div class="main_in_input">
                <div class="main_in_input_img"><img src="../img/icon_02.png" /></div>
                <div class="main_in_input_text"><input type="password" id="acc_Password" placeholder="请输入原密码" /></div>
            </div>
            <div class="main_in_input">
                <div class="main_in_input_img"><img src="../img/icon_02.png" /></div>
                <div class="main_in_input_text"><input type="password" id="acc_Passworddd" placeholder="请输入新密码" /></div>
            </div>
            <div class="main_in_input">
                <div class="main_in_input_img"><img src="../img/icon_02.png" /></div>
                <div class="main_in_input_text"><input type="password" id="acc_Passwordcc" placeholder="确认新密码" /></div>
            </div>
            <div style="height: 20px;clear: both;"></div>
            <div class="app_submit" onclick="doadd()">提&nbsp;交</div>
        </div>

<div class="outside_pull"></div>
<img src="../img/loading.gif" class="fade_out_img" id="fade_out_loading" />
	</body>
</html>
